<template>
  <div class="resource">
    <el-card shadow="hover">
      <div style="margin-bottom: 10px;">
        <i class="el-icon-search" />
        <span>筛选搜索</span>
        <div style="display: inline-block; margin-left: 20px;" v-if="openFlag">
          <el-button
            @click="search"
            icon="el-icon-search"
            size="mini"
            type="primary"
            >搜索</el-button
          >
          <el-button
            icon="el-icon-folder-opened"
            type="cyan"
            size="mini"
            @click="openSearch"
            >展开</el-button
          >
          <el-button @click="cancelData" icon="el-icon-refresh" size="mini"
            >重置</el-button
          >
        </div>
        <div style="display: inline-block; margin-left: 20px;" v-if="!openFlag">
          <el-button
            @click="search"
            icon="el-icon-search"
            type="primary"
            size="mini"
            >搜索</el-button
          >
          <el-button
            @click="openSearch"
            icon="el-icon-folder-opened"
            type="cyan"
            size="mini"
            >收起</el-button
          >
          <el-button @click="cancelData" icon="el-icon-refresh" size="mini"
            >重置</el-button
          >
        </div>
      </div>
      <el-row :gutter="20">
        <el-form
          ref="params"
          :model="params"
          label-width="130px"
          size="small"
          class="searchForm"
        >
          <el-col :span="8">
            <el-form-item label="订单编号:" prop="orderSn">
              <el-input
                v-model="params.orderSn"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单状态:" prop="state">
              <el-select
                v-model="params.state"
                filterable
                placeholder="请选择"
                clearable
                @change="search"
              >
                <el-option
                  v-for="item in stateOptions"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="流程状态:" prop="flowSerial">
              <el-select
                v-model="params.flowSerial"
                filterable
                placeholder="请选择流程"
                clearable
                @change="search"
              >
                <el-option
                  v-for="item in flowOptions"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="咨询公司:" prop="companyName" v-if="!openFlag">
              <el-input
                v-model="params.companyName"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="对接人:" prop="dockingPeople" v-if="!openFlag">
              <el-input
                v-model="params.dockingPeople"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="联系电话:"
              prop="dockingPhone"
              v-if="!openFlag"
            >
              <el-input
                v-model="params.dockingPhone"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="物流单号:" prop="wuLiu" v-if="!openFlag">
              <el-input
                v-model="params.wuLiu"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <!-- <el-form-item label="证书类型:" prop="status">
              <el-autocomplete
                class="inline-input"
                v-model="params.categoryName"
                :fetch-suggestions="querySearch"
                placeholder="请输入内容"
                value-key="categoryName"
                clearable
              ></el-autocomplete>
            </el-form-item> -->
            <el-form-item
              label="证书名称:"
              prop="certificateName"
              v-if="!openFlag"
            >
              <el-input
                v-model="params.certificateName"
                size="small"
                clearable
                @clear="search"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="电子证书出证日期:"
              v-if="!openFlag"
              prop="createTime"
            >
              <el-date-picker
                v-model="params.edHisDate"
                type="date"
                placeholder="选择日期"
                @change="search"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="纸质证书出证日期:"
              v-if="!openFlag"
              prop="createTime"
            >
              <el-date-picker
                v-model="params.paperHisDate"
                type="date"
                placeholder="选择日期"
                @change="search"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
    </el-card>

    <div class="container">
      <div class="handle-box">
        <!-- <el-button
          size="small"
          type="primary"
          icon="el-icon-plus"
          @click="handleAdd"
          class="mr10"
          >新增</el-button
        > -->
        <el-button
          type="danger"
          icon="el-icon-delete"
          class="handle-del mr10"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          >批量删除</el-button
        >
      </div>

      <!-- <el-card shadow="hover">
        <h4 style="margin-bottom:10px">已接单列表</h4> -->
      <el-table
        v-loading="loading"
        :data="tableData"
        border
        class="table"
        max-height="550"
        ref="multipleTable"
        header-cell-class-name="table-header"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          type="selection"
          width="50"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="orderSn"
          label="订单编号"
          align="center"
          min-width="200"
          fixed
        >
          <template slot-scope="scope">
            <span
              class="blue"
              style="text-decoration: underline; margin-left: 5px"
              @click="handleEditOrder(scope.$index, scope.row)"
              >{{ scope.row.orderSn }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          prop="certificateName"
          label="证书名称"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
          fixed
        ></el-table-column>
        <el-table-column label="规格说明" align="center" min-width="200" fixed>
          <template slot-scope="scope">
            {{ scope.row.specName }}
          </template>
        </el-table-column>

        <el-table-column
          label="咨询公司"
          min-width="150"
          align="center"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.companyName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="dockingPeople"
          label="对接人"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="sysName"
          label="业务人员"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="dockingPhone"
          label="联系电话"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column prop="address" align="center" width="120" show-overflow-tooltip label="客户地址"></el-table-column>
        <el-table-column prop="actualAddress" align="center" width="120" show-overflow-tooltip label="办公地址"></el-table-column>
        <el-table-column prop="region" align="center" width="120" show-overflow-tooltip label="经营范围"></el-table-column>
        <el-table-column label="营业执照" min-width="150" align="center">
          <template slot-scope="scope">
            <!-- <img
              v-if="scope.row.businessLicense != null"
              class="study_pic"
              :src="showUrl + JSON.parse(scope.row.businessLicense)[0]"
              alt=""
            /> -->
              <viewer >
                  <img
                    v-if="scope.row.businessLicense != null"
                    class="study_pic"
                    :src="showUrl + JSON.parse(scope.row.businessLicense)[0]"
                    alt=""
                    width="200"
                    height="180"
                  />
              </viewer>
          </template>
        </el-table-column>
        <el-table-column label="出证日期(电子)" align="center" width="155">
          <template slot-scope="scope">
            {{ formatT(scope.row.edHisDate) }}
          </template>
        </el-table-column>
        <el-table-column label="出证日期(纸质)" align="center" width="155">
          <template slot-scope="scope">
            {{ formatT(scope.row.paperHisDate) }}
          </template>
        </el-table-column>
        <!-- <el-table-column label="订单状态" align="center" min-width="150">
          <template slot-scope="scope">
            <span>{{ status(scope.row.state) }}</span>
          </template>
        </el-table-column> -->

        <el-table-column
          prop="orgPrice"
          label="订单金额"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          label="审核老师"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <!-- {{ scope.row.orgUserName }} -->
            <span
              class="blue"
              style="text-decoration: underline; margin-left: 5px"
              @click="handlePass(scope.row)"
              >{{ scope.row.orgUserName }}</span
            >
          </template>
        </el-table-column>
        <el-table-column label="订单状态" align="center" width="150">
          <template slot-scope="scope">
            <span>{{ status(scope.row.state) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="wuLiu"
          label="物流单号"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="remarks"
          label="备注说明"
          align="center"
          min-width="150"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column label="创建时间" align="center" min-width="155">
          <template slot-scope="scope">{{
            formatT(scope.row.createTime)
          }}</template>
        </el-table-column>
        <el-table-column
          label="操作"
          min-width="230"
          align="center"
          fixed="right"
        >
          <template slot-scope="scope">
            <!-- <el-button type="text" @click="handleEdit(scope.$index, scope.row)"
              >查看</el-button
            > -->
              <!-- v-if="scope.row.consult == 2" -->
            <el-button 
              type="text" 
              @click="downLoadPaper(scope.row.materialZip)" 
            >下载材料</el-button>
            <el-button
              type="text"
              @click="handleEditOrder(scope.$index, scope.row)"
              >订单详情</el-button
            >
            <el-button
              type="text"
              @click="handlePass(scope.row)"
            >指派老师
            </el-button>
            <!-- <el-button
              type="text"
              @click="handleUpload(scope.$index, scope.row)"
              v-if="
                scope.row.state == 4 ||
                  scope.row.state == 5 ||
                  scope.row.state == 6
              "
              >上传证书</el-button
            > -->
            <el-button
              type="text"
              v-if="scope.row.orgState == '1'"
              @click="handleProcess(scope.row)"
              >流程查看</el-button
            >
            <!-- <el-button></el-button> -->
            <!-- <el-button
              type="danger"
              size="mini"
              @click="handleDelete(scope.row)"
              >删除</el-button
            > -->
          </template>
        </el-table-column>
      </el-table>
      <!-- </el-card> -->
      <div class="pagination">
        <pagination
          v-show="pageTotal > 0"
          :total="pageTotal"
          :page.sync="params.pageNum"
          :limit.sync="params.pageSize"
          @pagination="getData00"
        />
      </div>
    </div>
    <!-- 查看编辑 -->
    <el-dialog
      :title="title666"
      :visible.sync="dialogVisible"
      v-if="dialogVisible"
      width="800px"
    >
      <el-tabs v-model="activeName" type="card">
        <el-tab-pane label="订单编辑" name="first">
          <el-form
            ref="formData"
            :model="formData"
            :rules="rules2"
            label-width="140px"
            size="small"
            class="form-box"
          >
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="订单编号" prop="orderSn">
                  <el-input v-model="formData.orderSn" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="咨询公司">
                  <el-input v-model="formData.companyName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="证书名称" prop="certificateName">
                  <el-input
                    v-model="formData.certificateName"
                    disabled
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="规格:" prop="specName">
                  <el-input v-model="formData.specName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="对接人" prop="dockingPeople">
                  <el-input
                    v-model="formData.dockingPeople"
                    disabled
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系电话" prop="dockingPhone">
                  <el-input v-model="formData.dockingPhone" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="营业执照">
                  <div
                    v-for="(item, index) in formData.businessLicense"
                    class="avatar6"
                    :key="index"
                  >
                <viewer>
                    <img
                      :src="showUrl + item"
                      alt=""
                      width="200"
                      height="180"
                    />
                </viewer>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="电子证书出证时间" prop="edHisDate">
                  <el-date-picker
                    v-model="formData.edHisDate"
                    type="date"
                    placeholder="选择出证日期"
                    value-format="yyyy-MM-dd"
                    :disabled="editFlags"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="纸质证书出证时间" prop="paperHisDate">
                  <el-date-picker
                    v-model="formData.paperHisDate"
                    type="date"
                    placeholder="选择出证日期"
                    value-format="yyyy-MM-dd"
                    :disabled="editFlags"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="订单状态" prop="state">
                  <el-select
                    v-model="formData.state"
                    filterable
                    placeholder="请选择"
                    clearable
                    disabled
                  >
                    <el-option
                      v-for="item in stateOptions"
                      :key="item.id"
                      :label="item.title"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="订单金额" prop="orgPrice">
                  <el-input v-model="formData.orgPrice" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="备注">
                  <el-input
                    autosize
                    type="textarea"
                    v-model="formData.remarks"
                    :disabled="editFlags"
                  ></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="12" v-if="formData.advancePic">
                <el-form-item label="预付款凭证" prop="advancePic">
                  <div
                    v-for="(item, index) in JSON.parse(
                      this.formData.advancePic
                    )"
                    :key="index"
                  >
                <viewer>
                    <img :src="showUrl + item.url" class="avatar" />
                </viewer>

                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="formData.printPicture">
                <el-form-item label="打印凭证" prop="printPicture">
                  <div
                    v-for="item in JSON.parse(
                      this.formData.printPicture
                    )"
                    :key="item.url"
                  >
                <viewer>
                    <img :src="showUrl + item.url" class="avatar" />
                </viewer>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="formData.finalPic">
                <el-form-item label="尾款凭证" prop="finalPic">
                  <div
                    v-for="item in JSON.parse(this.formData.finalPic)"
                    :key="item.url"
                  >
                <viewer>
                    <img :src="showUrl + item.url" class="avatar" />
                </viewer>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <span class="dialog-footer" v-if="!editFlags" style="float: right;">
            <el-button @click="dialogVisible = false">取消</el-button>
            <el-button @click="submitForm" type="primary">确定</el-button>
          </span>
        </el-tab-pane>
        <el-tab-pane label="流程操作" name="second">
          <el-form
            ref="formData"
            :model="formData"
            label-width="130px"
            size="small"
            class="form-box"
          >
            <el-row :gutter="20">
              <el-col :span="24" v-if="steps100[9].finish == 1">
                <el-form-item label="预排总时间">
                  <el-input
                    type="textarea"
                    autosize
                    placeholder="请输入XX人日"
                    v-model="formData.orgAllTime"
                    maxlength="200"
                    show-word-limit
                    class="inpWidth"
                  >
                  </el-input>
                  <el-button
                    class="save_btn"
                    type="primary"
                    size="mini"
                    @click="saveProcess(10)"
                    style="float:right"
                    >提交</el-button
                  >
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="steps100[10].finish == 1">
                <el-form-item label="机构合同评审">
                  <el-radio-group v-model="finish_sh1" @change="submitState1">
                    <el-radio :label="1">审核中</el-radio>
                    <el-radio :label="2">审核完成</el-radio>
                  </el-radio-group>
                  <el-button size="mini" style="float:right" type="primary" @click="tijiao_shqy1">提交</el-button>
                </el-form-item>
              </el-col>
              <el-col v-if="steps100[11].finish == 1" :span="24">
                <el-form-item label="预排上门审核时间">
                  <!-- <el-input
                    type="textarea"
                    autosize
                    placeholder="请输入预排上门审核时间"
                    v-model="formData.orgAuditTime"
                    maxlength="200"
                    show-word-limit
                    class="inpWidth"
                  >
                  </el-input> -->
                  <el-date-picker
                    value-format="yyyy-MM-dd"
                    v-model="formData.orgAuditTime"
                    type="date"
                    placeholder="选择日期">
                  </el-date-picker>
                  <el-button
                    class="save_btn"
                    type="primary"
                    size="mini"
                    @click="saveProcess(13)"
                    style="float:right"
                    >提交</el-button
                  >
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="steps100[12].finish == 1">
                <el-form-item label="上传计划表">
                  <el-button size="mini" style="float:right" type="primary" @click="tijiao_jhb">提交</el-button>
                  <el-upload
                    class="upload-demo"
                    :headers="headers"
                    :action="`${baseUrl}/goods/order/file/upload`"
                    :file-list="fileList333"
                    :on-remove="handleRemove333"
                    :on-success="handleSuccess333"
                    :limit="3"
                    :on-exceed="handleExceed333"
                    multiple
                  >
                    <el-button size="mini" type="text">选择文件</el-button>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="steps100[14].finish == 1">
                <el-form-item label="审核企业">
                  <el-radio-group v-model="finish_sh" @change="submitState">
                    <el-radio :label="1">审核中</el-radio>
                    <el-radio :label="2">审核完成</el-radio>
                  </el-radio-group>
                  <el-button size="mini" style="float:right" type="primary" @click="tijiao_shqy">提交</el-button>
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="steps100[16].finish == 1">
                <el-form-item label="档案评定">
                  <el-radio-group v-model="finish_pd" @change="submitState_pd">
                    <el-radio :label="1">出证</el-radio>
                    <el-radio :label="2">待整改</el-radio>
                  </el-radio-group>
                  <el-upload
                    v-if="finish_pd==2"
                    class="upload-demo"
                    :headers="headers"
                    :action="`${baseUrl}/goods/order/file/upload`"
                    :file-list="fileList999"
                    :on-remove="handleRemove999"
                    :on-success="handleSuccess999"
                    :limit="1"
                    :on-exceed="handleExceed999"
                    multiple
                  >
                    <el-button size="mini" type="text">选择文件</el-button>
                  </el-upload>
                  <el-input
                    v-if="finish_pd==2"
                    type="textarea"
                    autosize
                    placeholder="若评定通过，默认评定通过；若需整改，请输入整改内容"
                    v-model="formData.results"
                    maxlength="400"
                    show-word-limit
                    class="inpWidth"
                    style="display:block"
                  >
                  </el-input>
                  <el-button
                    class="save_btn"
                    type="primary"
                    @click="saveProcess(17)"
                    style="float:right"
                    >提交</el-button
                  >
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="steps100[17].finish == 1">
                <el-form-item label="上传证书">
                  <el-button style="float:right" size="mini" type="primary" @click="tijiao_zs">提交</el-button>
                  <el-upload
                    ref="upload1"
                    :headers="headers"
                    :action="`${baseUrl}/goods/order/image/upload`"
                    :limit="5"
                    :on-exceed="uploadOverrun"
                    :on-success="handlePicsUrl1"
                    :on-remove="handleRemove1"
                    :file-list="fileList_shui"
                    multiple
                    accept=".jpg,.jpeg,.png,.gif,.pdf"
                    list-type="picture-card"
                  >
                    <i class="el-icon-plus" />
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="steps100[20].finish == 1">
                <el-form-item label="物流单号">
                  <el-input
                    v-model="formData.wuLiu"
                    :disabled="editFlags"
                    class="inpWidth"
                  ></el-input>
                  <el-button
                    class="save_btn"
                    type="primary"
                    @click="saveProcess(21)"
                    style="float:right"
                    >提交</el-button
                  >
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="steps100[21].finish == 1">
                <el-form-item label="上传发票">
                  <el-button size="mini" type="primary" @click="tijiao_fp" style="float:right">提交</el-button>
                  <el-upload
                    class="upload-demo"
                    :headers="headers"
                    :action="`${baseUrl}/goods/order/file/upload`"
                    :file-list="fileList444"
                    :on-remove="handleRemove444"
                    :on-success="handleSuccess444"
                    :limit="3"
                    :on-exceed="handleExceed333"
                    multiple
                  >
                    <el-button size="mini" type="text">选择文件</el-button>
                    <!-- <el-button size="small" plain @click.stop="saveProcess(22)"
                      >提交</el-button
                    > -->
                  </el-upload>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>

    <!-- 流程查看 -->
    <el-dialog title="流程查看" :visible.sync="dialogVisible1010" width="800px">
      <div class="progress_box" v-for="(item, index) in steps" :key="index">
        <div class="left_c" v-if="item.finish == 1">已完成</div>
        <div class="left" v-if="item.finish == 0">处理中</div>
        <div class="center">
          <i
            class="el-icon-star-on"
            style="color:#000"
            v-if="item.finish == 1"
          ></i>
          <i
            class="el-icon-star-on"
            style="color:#888"
            v-if="item.finish == 0"
          ></i>
        </div>
        <!-- <div class="right_c"> -->
				<div :class="[item.finish==1?'right_c':'right']">
          <div class="top88" v-if="item.finish == 1">
            <span class="time88">{{ item.updateTime }}</span>
            <span
              class="loading88"
              v-if="item.accessory && item.flowSerial != 18"
              @click="downLoadPaper(item.accessory)"
              >下载附件</span
            >
            <span
              class="loading88"
              v-if="item.accessory && item.flowSerial == 18"
              @click="ViewCert(item.accessory)"
              >预览证书</span
            >
          </div>
          <div class="title88">[{{ item.flowName }}]</div>
          <div class="desc88" v-if="item.finish == 1 && item.context">
            {{ item.context }}
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 预览证书 -->
    <el-dialog title="证书预览" :visible.sync="certVisible" width="700px">
      <div v-for="(item,index) in cert_view" :key="index" class="father_box">
        <img :src="showUrl + item.url" width="200" height="240"/>
        <div class="son_box">水印证书</div>
      </div>
    </el-dialog>

    <!-- 上传电子证书 -->
    <el-dialog :title="wuliuTitle" :visible.sync="wuliuVisible" width="55%">
      <el-form
        ref="wuliuForm"
        :model="wuliuForm"
        label-width="130px"
        :rules="wuliuRules"
      >
        <el-form-item label="电子证书(水印)">
          <el-upload
            ref="upload1"
            :headers="headers"
            :action="`${baseUrl}/goods/order/image/upload`"
            :limit="10"
            :on-exceed="uploadOverrun"
            :on-success="handlePicsUrl1"
            :on-remove="handleRemove1"
            multiple
            accept=".jpg,.jpeg,.png,.gif,.pdf"
            list-type="picture-card"
          >
            <i class="el-icon-plus" />
          </el-upload>
          <el-button
            type="primary"
            style="margin-top: 10px;"
            @click="saveProcess(18)"
            >上传</el-button
          >
        </el-form-item>
        <el-form-item label="电子证书(清晰)">
          <el-upload
            ref="upload2"
            :headers="headers"
            :action="`${baseUrl}/goods/order/image/upload`"
            :limit="10"
            :on-exceed="uploadOverrun"
            :on-success="handlePicsUrl2"
            :on-remove="handleRemove2"
            multiple
            accept=".jpg,.jpeg,.png,.gif"
            list-type="picture-card"
          >
            <i class="el-icon-plus" />
          </el-upload>
          <el-button
            type="primary"
            style="margin-top: 10px;"
            @click="saveProcess(20)"
            >上传</el-button
          >
        </el-form-item>
      </el-form>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button @click="cancelPost">取 消</el-button>
        <el-button type="primary" @click="sumitPost">上 传</el-button>
        <el-button type="warning" @click="exportPicFunc">下 载</el-button>
      </span> -->
    </el-dialog>

    <!-- 订单分配老师 -->
    <el-dialog title="分配老师" :visible.sync="teacherVisible" width="650px">
      <el-form
        ref="teacherForm"
        :model="teacherForm"
        label-width="130px"
        :rules="teacherRules"
      >
        <el-form-item label="选择审核老师" prop="orgUserId">
          <el-select
            v-model="teacherForm.orgUserId"
            filterable
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in teacherLists"
              :key="item.userId"
              :label="item.userName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="teacherVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit_teacher">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import DomToImage from "dom-to-image";
import {
  orderReceive_List,
  updateOrder,
  checkTeacher,
  record,
  delOrder,
  uploadProductImg,
  queryProcess,
  addProcess,
  updateProcess1,
  fetchOrder_org
} from "@/api/order/orderReceiveAds";
import { listUser } from "@/api/system/user";
import { list } from "@/api/materialScience/materialScience";
import { certificateList } from "@/api/certificate/certificateAds";
import { teacherList, checkTeacherList } from "@/api/teacher/teacherAds";
import { getToken } from "@/utils/auth";
import { copyFileSync } from "fs";
import { setTimeout } from "timers";
export default {
  components: {},
  props: [],
  data() {
    return {
      certVisible: false,
      activeName: "second",
      finish_sh1:1,
      finish_sh: 1,
      srcList: [
        'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
      ],
      finish_pd:1,
      cert_view:[],
      // 编辑框里用于比对的流程
      steps100: [],
      steps: [],
      dialogVisible1010: false,
      // 上传计划表
      fileList333: [],
      fileList999: [],
      // 上传发票
      fileList444: [],
      // 水印照片
      dialogVisible_shui: false,
      fileList_shui: [] /*用于更改展示回显*/,
      huPic: [], // 用于存数据
      dialogImageUrl_shui: "",
      urlArr_shui: [] /*用于数据传输 */,

      visible: false,
      paperVisible: false,
      paperForm: {},
      baseUrl: process.env.VUE_APP_BASE_API,
      // picsFileList: [],
      // picsFileList22: [],

      teacherId: undefined,
      teacherLists: [],
      dialogVisible_teacher: false,
      cateList2: [],
      // 非多个禁用
      multiple: true,
      //删除
      ids: [],
      headers: { Authorization: "Bearer " + getToken() },
      upImage: process.env.VUE_APP_BASE_API,
      flowOptions: [
        { id: 8, title: "机构接单" },
        { id: 9, title: "招商部上传付款凭证" },
        { id: 10, title: "机构预排总时间" },
        { id: 11, title: "机构合同评审中" },
        { id: 12, title: "企业或咨询老师上传打印图片" },
        { id: 13, title: "评审通过，预排上门时间" },
        { id: 14, title: "机构排计划" },
        { id: 15, title: "机构审核企业中" },
        { id: 16, title: "审核完成待评审" },
        { id: 17, title: "机构档案评定" },
        { id: 18, title: "机构出证打水印，上传照片" },
        { id: 19, title: "招商部上传尾款照片" },
        { id: 20, title: "机构上传清晰证书" },
        { id: 21, title: "机构邮寄证书" },
        { id: 22, title: "完成" }
      ],
      stateOptions: [
        {
          id: 4,
          title: "处理中"
        },
        {
          id: 5,
          title: "待出证"
        },
        {
          id: 6,
          title: "待签收"
        },
        {
          id: 7,
          title: "已完成"
        },
        {
          id: 8,
          title: "已拒绝"
        }
      ],
      title666: "",
      rules2: {
        phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
        companyName: [
          { required: true, message: "请输入公司名称", trigger: "blur" }
        ],
        linkman: [
          { required: true, message: "请输入联系人名称", trigger: "blur" }
        ],
        businessLicense: [
          { required: true, message: "请上传图片", trigger: "blur" }
        ],
        wuLiu: [{ required: true, message: "请填写物流单号", trigger: "blur" }]
      },
      input: "",
      openFlag: true,
      loading: true,
      //数据
      tableData: [],
      params: {
        pageNum: 1,
        pageSize: 10,
        orgState: "1"
        // position: 1 // 机构1
      },
      pageTotal: 0,
      dialogVisible: false, // 是否展示编辑页面
      // 新增/编辑数据
      formData: {
        businessLicense: "",
        results:""
      },
      customer: {
        customerId: ""
      },
      paramsFlag: 0,
      editFlags: true,

      wuliuTitle: "",
      wuliuVisible: false,
      wuliuForm: {},
      wuliuRules: {
        edHisPic: [
          { required: true, message: "请上传电子证书", trigger: "blur" }
        ]
      },

      teacherVisible: false,
      teacherForm: {},
      teacherRules: {
        orgUserId: [
          { required: true, message: "请选择一位审批老师", trigger: "blur" }
        ]
      },
      materialSciences: []
    };
  },
  computed: {},
  created() {
    if (this.$route.params.state) {
      this.params.state = this.$route.params.state;
      this.getData00();
    } else {
      this.getData00();
    }
    this.getTeacherData();
  },
  mounted() {
    this.changeType();
  },
  watch: {},
  methods: {
    tijiao_jhb(){
      if(this.fileList333.length>=1){
        updateOrder({
          id: this.formData.id,
          skedWord: JSON.stringify(this.fileList333)
        }).then(res => {
          if (res.code == 200) {
            this.process(this.formData.id, 14, "", JSON.stringify(this.fileList333));
          } else {
            this.$message.error("操作失败");
          }
        });
      }else{
        this.$message.error("请上传计划表");
      }
    },
    tijiao_zs(){
      if(this.huPic.length>=1){
        updateOrder({
          id: this.formData.id,
          state: 5,
          edHisPic: JSON.stringify(this.huPic),
          distinctPic: JSON.stringify(this.huPic)
        }).then(res => {
          if (res.code == 200) {
            this.process(
              this.formData.id,
              18,
              "",
              JSON.stringify(this.huPic)
            );
          } else {
            this.$message.error("操作失败");
          }
        });
      }else{
        this.$message.error("请上传证书");
      }
    },
    tijiao_fp(){
      if(this.fileList444.length>=1){
        updateOrder({
          id: this.formData.id,
          invoice: JSON.stringify(this.fileList444),
          state: 7
        }).then(res => {
          if (res.code == 200) {
            this.process(this.formData.id, 22, "", JSON.stringify(this.fileList444));
          } else {
            this.$message.error("修改订单失败");
          }
        });
      }else{
        this.$message.error("请上传发票");
      }
    },
    tijiao_shqy(){
      if (this.finish_sh == 2) {
        this.process(this.formData.id,15,'审核通过','')
        this.process(this.formData.id,16,'审核通过','')
      } else {
        updateProcess1({
          orderId: this.formData.id,
          flowSerial: 16,
          context:'审核中',
          finish: 0
        }).then(res => {
          if (res.code == 200) {
            this.$message.success("操作成功");
            this.dialogVisible=false;
          } else {
            this.$message.error("操作失败");
          }
        });
      }
    },
    tijiao_shqy1(){
      if (this.finish_sh1 == 2) {
        this.process(this.formData.id,11,'审核通过','')
      } else {
        updateProcess1({
          orderId: this.formData.id,
          flowSerial: 11,
          context:'审核中',
          finish: 0
        }).then(res => {
          if (res.code == 200) {
            this.$message.success("操作成功");
            this.dialogVisible=false;
          } else {
            this.$message.error("操作失败");
          }
        });
      }
    },
    // 点击审批老师，重新分配审批老师
    handlePass(row) {
      this.teacherVisible = true;
      this.teacherForm = row;
    },
    submit_teacher() {
      this.$refs["teacherForm"].validate(valid => {
        if (valid) {
          updateOrder(this.teacherForm).then(res => {
            if (res.code == 200) {
              this.teacherVisible = false;
              this.getData00();
            }
          });
        }
      });
    },
    getTeacherData() {
      listUser({
        pageNum: 1,
        pageSize: 1000,
        orgTeacher: "2"
      }).then(res => {
        this.teacherLists = res.rows;
      });
    },
    // 点击查看流程
    handleProcess(row) {
      this.steps = [];
      queryProcess({
        orderId: row.id
      }).then(res => {
        if (res.code == 200) {
          res.rows.forEach((item, index) => {
            if (item.flowSerial > 7) {
              this.steps.push(item);
            }
          });
          this.dialogVisible1010 = true;
        }
      });
    },
    // 点击下载附件
    downLoadPaper(val) {
      let value = JSON.parse(val);
      let that = this;
      value.forEach(item => {
        this.downloadFile(item.url);
      });
    },
    downloadFile(url) {
      const iframe = document.createElement("iframe");
      iframe.style.display = "none"; // 防止影响页面
      iframe.style.height = 0; // 防止影响页面
      iframe.src = this.showUrl + url;
      document.body.appendChild(iframe); // 这一行必须，iframe挂在到dom树上才会发请求
      // 1分钟之后删除（onload方法对于下载链接不起作用，就先抠脚一下吧）
      setTimeout(() => {
        iframe.remove();
      }, 1 * 60 * 1000);
    },
    // 点击预览证书
    ViewCert(val){
      this.cert_view = JSON.parse(val);
      this.certVisible = true;
    },
    // 触发流程
    process(id, flowSerial, context, accessory) {
      updateProcess1({
        orderId: id,
        flowSerial: flowSerial,
        context: context,
        accessory: accessory,
        finish: 1
      }).then(res => {
        if (res.code == 200) {
          this.$message.success("操作成功");
          this.dialogVisible=false;
          this.getData00();
          // console.log('触发流程成功')
        } else {
          this.$message.error("操作失败");
        }
      });
    },
    // 上传计划表
    handleRemove333(file) {
      this.fileList333.forEach((item, i) => {
        if (item.url == file.url) {
          this.fileList333.splice(i, 1);
        }
      });
    },
    handleRemove999(file) {
      this.fileList999.forEach((item, i) => {
        if (item.url == file.url) {
          this.fileList999.splice(i, 1);
        }
      });
    },
    handleRemove444(file) {
      this.fileList444.forEach((item, i) => {
        if (item.url == file.url) {
          this.fileList444.splice(i, 1);
        }
      });
      if(this.fileList444.length >= 1){
        updateOrder({
          id: this.formData.id,
          invoice: JSON.stringify(this.fileList444),
          state: 7
        }).then(res => {
          if (res.code == 200) {
            this.process(this.formData.id, 22, "", JSON.stringify(this.fileList444));
          } else {
            this.$message.error("修改订单失败");
          }
        });
      }else{
        updateOrder({
          id: this.formData.id,
          invoice: '',
          state: 6
        }).then(res => {
          if (res.code == 200) {
            updateProcess1({
              orderId: this.formData.id,
              flowSerial: 22,
              context: "",
              accessory: "",
              finish: '0'
            }).then(res => {
              if (res.code == 200) {
                this.$message.success("操作成功");
              } else {
                this.$message.error("操作失败");
              }
            });
          } else {
            this.$message.error("修改订单失败");
          }
        });
      }
    },
    handleSuccess333(res, file) {
      if (res.code == 200) {
        this.fileList333.push({
          name: file.name,
          url: res.data
        });
      }
    },
    handleSuccess999(res, file) {
      if (res.code == 200) {
        this.fileList999.push({
          name: file.name,
          url: res.data
        });
      }
    },
    handleSuccess444(res, file) {
      if (res.code == 200) {
        this.fileList444.push({
          name: file.name,
          url: res.data
        });
      }
    },
    handleExceed333(files, fileList) {
      this.$message.warning(`当前限制仅可上传 3 个文件`);
    },
    handleExceed999(files, fileList) {
      this.$message.warning(`当前限制仅可上传 1 个文件`);
    },
    upload_shui(file) {
      let formData = new FormData();
      formData.append(file.filename, file.file, file.file.name);
      uploadProductImg(formData).then(res => {
        // console.log(res);
        if (res.code == 200) {
          this.$message.success("上传成功");
          this.fileList_shui.push({
            name: res.url,
            url: this.imgUrl + res.url
          });
          this.urlArr_shui.push(file.url);
          console.log(this.fileList_shui);
        } else {
          this.$message.error("上传失败");
        }
      });
    },
    // 放大
    handlePictureCardPreview_shui(file, fileList) {
      console.log(file);
      this.dialogImageUrl_shui = file.url;
      this.dialogVisible_shui = true;
    },
    // 删除
    handleRemove_shui(file, fileList) {
      this.urlArr_shui = [];
      console.log(file, fileList, this.fileList_shui);
      if (fileList.length == 0) {
        // 用于规避最后一个删除选项
        // this.form.invitationPosterUrl = null;
        this.fileList_shui = [];
      } else {
        fileList.forEach(item => {
          console.log(item);
          this.urlArr_shui.push(item.name);
          console.log(this.urlArr_shui, "移除后的剩余图片路径");
        });
        for (let i = 0; i < this.fileList_shui.length; i++) {
          if (file.name == this.fileList_shui[i].name) {
            this.fileList_shui.splice(i, 1);
            console.log(i);
          }
        }
      }
    },
    // 成功
    handleSuccess_shui(res, file, fileList) {
      this.fileList_shui.push({
        name: res.url,
        url: this.imgUrl + res.url
      });
      this.$message.success("上传成功");
      this.urlArr_shui.push(file.url);
      console.log(res, file, fileList);
    },
    // 付款凭证
    handleAvatarSuccess2(res) {
      this.formData.advancePic = res.data;
    },
    // 尾款凭证
    handleAvatarSuccess3(res) {
      this.formData.finalPic = res.data;
    },
    // 用于审批记录formatter回显
    queshi(row) {
      let arr6 = [];
      // 字符串转数组
      arr6 = row.materialName.split(",");
      let arr8 = [];
      console.log(arr6);
      // 一级循环参照
      for (let i = 0; i < this.materialSciences.length; i++) {
        // 二级循环赋值
        for (let j = 0; j < arr6.length; j++) {
          if (this.materialSciences[i].id == arr6[j]) {
            arr8.push(this.materialSciences[i].materialName);
          }
        }
      }
      return arr8.join(",");
    },
    // 获取材料列表
    changeType() {
      list({
        pageNum: 1,
        pageSize: 9999
      }).then(res => {
        console.log(res);
        if (res.code == 200) {
          this.materialSciences = res.rows;
          console.log(this.materialSciences);
        }
      });
    },
    // 点击下载证书
    exportPicFunc() {
      // console.log(this.picsFileList)
      // this.picsFileList.forEach(item => {
      //   if (item.url) {
      //     this.downLoad('电子证书',item.url)
      //   }
      // })

      let urls = this.wuliuForm.edHisPic;
      urls.forEach(item => {
        this.downLoad("电子证书", this.imgUrl + item);
      });

      // let node = this.$refs.previewImg;
      // let that = this;
      // console.log(node,'node')
      // DomToImage.toPng(node)
      //   .then(function (dataUrl) {
      //     console.log(dataUrl,'dataUrl')
      //     var oLink = document.createElement("a");
      //     oLink.download = "pic.png";
      //     oLink.href = dataUrl;
      //     oLink.click();
      //     that.$nextTick(() => {
      //       that.$message.success("水印图片下载成功");
      //     });
      //   })
      //   .catch(function (error) {
      //     that.$message.error("下载失败");
      //     console.log(error,'error')
      //   });
    },
    getImageDataURL(image) {
      const canvas = document.createElement("canvas");
      canvas.width = image.width;
      canvas.height = image.height;
      const ctx = canvas.getContext("2d");
      ctx.drawImage(image, 0, 0, image.width, image.height);
      const extension = image.src
        .substring(image.src.lastIndexOf(".") + 1)
        .toLowerCase();
      return canvas.toDataURL("image/" + extension, 1);
    },
    downLoad(downloadName, url) {
      const tag = document.createElement("a");
      tag.setAttribute("download", downloadName.replace(/\./g, "。"));
      const image = new Image();
      image.src = url + "?time=" + new Date().getTime();
      image.setAttribute("crossOrigin", "Anonymous");
      image.onload = () => {
        tag.href = this.getImageDataURL(image);
        tag.click();
      };
    },
    uploadImage(url) {
      // console.log(url);
      let image = new Image();
      image.src = url;
      image.onload = () => {
        console.log("asdasd");
        let canvas = document.createElement("canvas");
        canvas.width = image.width;
        canvas.height = image.height;
        let ctx = canvas.getContext("2d");
        ctx.drawImage(image, 0, 0, image.width, image.height);
        canvas.toBlob(blob => {
          let url = URL.createObjectURL(blob);
          this.download(url, "电子证书");
          // 用完释放URL对象
          URL.revokeObjectURL(url);
        });
      };
      image.click();
      console.log("ok");
    },
    download(href, name) {
      let eleLink = document.createElement("a");
      eleLink.download = name;
      eleLink.href = href;
      eleLink.click();
      eleLink.remove();
    },
    // 图片列表超出限制数量
    uploadOverrun: function() {
      this.$message({
        type: "error",
        message: "上传文件个数超出限制!最多上传5张图片!"
      });
    },
    // 上传电子证书
    handleUpload(index, row) {
      this.wuliuTitle = "电子证书";
      // this.wuliuForm = JSON.parse(JSON.stringify(row));
      // if (!this.wuliuForm.edHisPic) {
      //   this.wuliuForm.edHisPic = [];
      //   this.picsFileList = [];
      // } else {
      //   this.picsFileList = [];
      //   this.wuliuForm.edHisPic = JSON.parse(this.wuliuForm.edHisPic);
      //   this.wuliuForm.edHisPic.forEach(item => {
      //     this.picsFileList.push({
      //       name: this.wuliuForm.edHisPic,
      //       url: this.imgUrl + item
      //     });
      //   });
      // }
      this.wuliuVisible = true;
      this.wuliuForm.id = row.id;
      this.wuliuForm.huPic = [];
      this.wuliuForm.certPic = [];
      let that = this;
      setTimeout(function() {
        that.$refs.upload1.clearFiles();
        that.$refs.upload2.clearFiles();
      }, 100);
    },
    // 水印证书上传
    handlePicsUrl1(res, file, fileList) {
      if (res.code === 200) {
        this.fileList_shui.push({
          name: file.name,
          url: this.showUrl + res.data
        });
        this.huPic.push({
          name: file.name,
          url: res.data
        });
        
        console.log(this.fileList_shui, "水印证书上传");
      }
    },
    // 水印证书移除
    handleRemove1(file) {
      for (let i = 0; i < this.fileList_shui.length; i++) {
        let url;
        if (file.response === undefined) {
          url = file.url;
        } else {
          url = file.response.data;
        }
        if (this.fileList_shui[i].url === url) {
          this.huPic.splice(i, 1);
          this.fileList_shui.splice(i, 1);
        }
      }
      // if (this.huPic.length >= 1) {
      //   updateOrder({
      //     id: this.formData.id,
      //     state: 5,
      //     edHisPic: JSON.stringify(this.huPic),
      //     distinctPic: JSON.stringify(this.huPic)
      //   }).then(res => {
      //     if (res.code == 200) {
      //       this.process(
      //         this.formData.id,
      //         18,
      //         "",
      //         JSON.stringify(this.wuliuForm.huPic)
      //       );
      //     } else {
      //       this.$message.error("保存失败");
      //     }
      //   });
      // } else {
      //   updateOrder({
      //     id: this.formData.id,
      //     state: 4,
      //     edHisPic: "",
      //     distinctPic: ""
      //   }).then(res => {
      //     if (res.code == 200) {
      //       updateProcess1({
      //         orderId: this.formData.id,
      //         flowSerial: 18,
      //         context: '',
      //         accessory: '',
      //         finish: '0'
      //       }).then(res => {
      //         if (res.code == 200) {
      //           this.$message.success("操作成功");
      //         } else {
      //           this.$message.error("操作失败");
      //         }
      //       });
      //     }
      //   });
      // }

      // for (var i = 0; i < this.wuliuForm.edHisPic.length; i++) {
      //   // 这里存在两种情况
      //   // 1. 如果所删除图片是刚刚上传的图片，那么图片地址是file.response.data.url
      //   //    此时的file.url虽然存在，但是是本机地址，而不是远程地址。
      //   // 2. 如果所删除图片是后台返回的已有图片，那么图片地址是file.url
      //   var url;
      //   if (file.response.code != 200) {
      //     url = file.url;
      //   } else {
      //     url = file.response.url;
      //   }
      //   if (this.wuliuForm.edHisPic[i] == url) {
      //     this.wuliuForm.edHisPic.splice(i, 1);
      //     this.$refs.pictureUpload.handleRemove(file);
      //   }
      // }
    },
    // 清晰证书上传
    handlePicsUrl2(res, file, fileList) {
      if (res.code === 200) {
        this.wuliuForm.certPic.push({
          name: file.name,
          url: res.data
        });
        console.log(this.wuliuForm.certPic, "清晰证书上传");
      }
    },

    // 清晰证书移除
    handleRemove2(file) {
      for (var i = 0; i < this.wuliuForm.certPic.length; i++) {
        var url;
        if (file.response === undefined) {
          url = file.url;
        } else {
          url = file.response.data;
        }
        if (this.wuliuForm.certPic[i].url === url) {
          this.wuliuForm.certPic.splice(i, 1);
        }
      }
    },

    handleEditPost(index, row) {
      this.wuliuForm = row;
      this.wuliuTitle = "修改物流单号";
      this.wuliuVisible = true;
    },
    sumitPost() {
      this.$refs["wuliuForm"].validate(valid => {
        if (valid) {
          if (this.wuliuForm.edHisPic) {
            this.wuliuForm.edHisPic = JSON.stringify(this.wuliuForm.edHisPic);
          } else {
            this.wuliuForm.edHisPic = "";
          }
          updateOrder(this.wuliuForm).then(res => {
            if (res.code == 200) {
              this.$message.success("保存成功");
              this.wuliuVisible = false;
              this.wuliuForm = {};
              this.getData00();
            } else {
              this.$message.error("保存失败");
              this.wuliuVisible = false;
              this.getData00();
            }
          });
        }
      });
    },
    cancelPost() {
      this.wuliuVisible = false;
      this.wuliuForm.trackingNumber = "";
    },

    // 查询证书类别列表
    getCateList() {
      this.loading = true;
      certificateList({
        pageNum: 1,
        pageSize: 9999
      }).then(res => {
        this.loading = false;
        if (res.code == 200) {
          this.cateList2 = res.rows;
          // this.cateList = res.rows;
        } else {
          this.msgError("查询失败！");
        }
      });
    },
    querySearch(queryString, cb) {
      console.log(queryString, this.cateList2);
      var restaurants = this.cateList2;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return restaurant => {
        return (
          restaurant.categoryName
            .toLowerCase()
            .indexOf(queryString.toLowerCase()) === 0
        );
      };
    },
    // 键值配对
    status(val) {
      var str = this.stateOptions.find(function(item) {
        return item.id == val;
      });
      if (str) return str.title;
    },
    // 键值配对
    status2(val) {
      var str = this.cateList2.find(function(item) {
        return item.id == val;
      });
      if (str) return str.categoryName;
    },
    handleAvatarSuccess(res, file) {
      if (res.code == 200) {
        this.formData.businessLicense = res.url;
        console.log(this.formData.businessLicense);
        this.$message.success(`上传成功`);
      }
    },
    // 点击触发流程
    saveProcess(i) {
      if (i == 10) {
        if (this.formData.orgAllTime) {
          updateOrder({
            id: this.formData.id,
            orgAllTime: this.formData.orgAllTime
          }).then(res => {
            if (res.code == 200) {
              this.process(this.formData.id, 10, this.formData.orgAllTime, "");
              // this.process(this.formData.id, 11, "", "");
            }
          });
        } else {
          return this.$message.error("预排总时间不能为空");
        }
      }
      if (i == 13) {
        if (this.formData.orgAuditTime) {
          updateOrder({
            id: this.formData.id,
            orgAuditTime: this.formData.orgAuditTime
          }).then(res => {
            if (res.code == 200) {
              this.process(
                this.formData.id,
                13,
                this.formData.orgAuditTime,
                ""
              );
            }
          });
        } else {
          return this.$message.error("预排上门审核时间不能为空");
        }
      }
      if (i == 12) {
        // if (this.fileList333.length >= 1) {
          let file = JSON.stringify(this.fileList333);
          updateOrder({
            id: this.formData.id,
            skedWord: file
          }).then(res => {
            if (res.code == 200) {
              this.process(this.formData.id, 13, "", file);
            }
          });
        // } else {
          // return this.$message.error("计划表不能为空");
        // }
      }
      if (i == 15) {
        this.process(this.formData.id, 15, "", "");
        this.process(this.formData.id, 16, "", "");
      }
      if (i == 17) {
        if(this.finish_pd==1){
          this.process(this.formData.id, 17, '评定通过', "");
        }else{
          console.log(this.formData,'form')
          let w = this.fileList999.length>=1?JSON.stringify(this.fileList999):'';
          this.process(this.formData.id, 17, '评定失败:'+(this.formData.results == undefined?'待整改':this.formData.results), w);
        }
      }
      if (i == 18) {
        if (this.wuliuForm.huPic.length >= 1) {
          updateOrder({
            id: this.wuliuForm.id,
            state: 5,
            edHisPic: JSON.stringify(this.wuliuForm.huPic)
          }).then(res => {
            if (res.code == 200) {
              this.process(
                this.wuliuForm.id,
                18,
                "",
                JSON.stringify(this.wuliuForm.huPic)
              );
            }
          });
        } else {
          return this.$message.error("请上传水印版证书后点击按钮");
        }
      }
      if (i == 20) {
        if (this.wuliuForm.certPic.length >= 1) {
          updateOrder({
            id: this.wuliuForm.id,
            distinctPic: JSON.stringify(this.wuliuForm.certPic)
          }).then(res => {
            if (res.code == 200) {
              this.process(
                this.wuliuForm.id,
                20,
                "",
                JSON.stringify(this.wuliuForm.certPic)
              );
            }
          });
        } else {
          return this.$message.error("请上传清晰版证书后点击按钮");
        }
      }
      if (i == 21) {
        if (this.formData.wuLiu) {
          updateOrder({
            id: this.formData.id,
            state: 6,
            wuLiu: this.formData.wuLiu
          }).then(res => {
            if (res.code == 200) {
              this.process(this.formData.id, 21, this.formData.wuLiu, "");
            }
          });
        } else {
          return this.$message.error("请填写完物流单号后点击按钮");
        }
      }
      if (i == 22) {
        if (this.fileList444.length >= 1) {
          let file4 = JSON.stringify(this.fileList444);
          updateOrder({
            id: this.formData.id,
            invoice: file4,
            state: 7
          }).then(res => {
            if (res.code == 200) {
              this.process(this.formData.id, 22, "", file4);
            } else {
              this.$message.error("修改订单失败");
            }
          });
        } else {
          return this.$message.error("上传发票不能为空");
        }
      }
    },

    // 新增修改的方法
    submitForm() {
      this.$refs["formData"].validate(valid => {
        if (valid) {
          if (this.fileList333.length >= 1) {
            this.formData.skedWord = JSON.stringify(this.fileList333);
          } else {
            this.formData.skedWord = "";
          }
          this.formData.businessLicense = JSON.stringify(
            this.formData.businessLicense
          );
          updateOrder(this.formData).then(res => {
            if (res.code == 200) {
              this.$message.success("保存成功");
              this.dialogVisible = false;
              this.formData = {};
              this.getData00();
            } else {
              this.$message.error("保存失败");
              this.dialogVisible = false;
              this.getData00();
            }
          });
        }
      });
    },
    // 打开搜索
    openSearch() {
      this.openFlag = !this.openFlag;
    },
    // 重置搜索框
    cancelData() {
      this.params={
        pageNum: 1,
        pageSize: 10,
        orgState: "1"
      }
      this.resetForm("params");
      this.getData00();
    },
    handleAdd() {
      this.formData = {
        businessLicense: ""
      };
      this.dialogVisible = true;
      this.title666 = "新增";
    },
    handleEdit(index, row) {
      let rowCopy = JSON.parse(JSON.stringify(row));
      this.formData = rowCopy;
      this.fileList333 = row.skedWord ? JSON.parse(row.skedWord) : [];
      this.formData.businessLicense = JSON.parse(row.businessLicense);
      this.editFlags = true;
      this.dialogVisible = true;
      this.title666 = "查看订单";
      console.info(this.formData)
    },
    submitState(e) {
      this.finish_sh=e;
    },
    submitState1(e) {
      this.finish_sh1=e;
    },
    submitState_pd(e){
      this.finish_pd=e;
      // this.$forceUpdate()
      console.log(this.results,e)
    },
    handleEditOrder(index, row) {
      this.activeName = "second";
      this.fileList_shui = [];
      this.huPic = [];
      let rowCopy = JSON.parse(JSON.stringify(row));
      this.formData = rowCopy;
      this.fileList333 = row.skedWord ? JSON.parse(row.skedWord) : [];
      this.fileList444 = row.invoice ? JSON.parse(row.invoice) : [];
      if (row.state == 6 || row.state == 7) {
        this.fileList444 = row.invoice ? JSON.parse(row.invoice) : [];
      }
      this.huPic = row.edHisPic&&row.edHisPic!='null' ? JSON.parse(row.edHisPic) : [];
      if (row.edHisPic&&row.edHisPic!='null') {
        let arr = JSON.parse(row.edHisPic);
        for (let j = 0; j < arr.length; j++) {
          arr[j].url = this.showUrl + arr[j].url;
        }
        this.fileList_shui = arr;
      } else {
        this.fileList_shui = [];
      }
      if (
        row.state == 4 ||
        row.state == 5 ||
        row.state == 6 ||
        row.state == 7
      ) {
        // 获取评定结果
        queryProcess({
          orderId: row.id,
          flowSerial: 17
        }).then(res => {
          if (res.code == 200) {
            if(res.rows[0].context=='评定通过'){
              this.finish_pd=1;
              // this.$set(this.formData, "results", res.rows[0].context);
            }else{
              this.finish_pd=2;
              this.$set(this.formData, "results", res.rows[0].context.substring(5));
              this.fileList333 = res.rows[0].accessory ? JSON.parse(res.rows[0].accessory) : [];
            }
          }
        });
      }
      queryProcess({
        orderId: row.id,
        flowSerial: 16
      }).then(res => {
        if (res.code == 200) {
          if (res.rows[0].finish == '1') {
            this.finish_sh = 2;
          } else {
            this.finish_sh = 1;
          }
        }
      });
      queryProcess({
        orderId: row.id,
        flowSerial: 11
      }).then(res => {
        if (res.code == 200) {
          if (res.rows[0].finish == '1') {
            this.finish_sh1 = 2;
          } else {
            this.finish_sh1 = 1;
          }
        }
      });
      this.formData.businessLicense = JSON.parse(row.businessLicense);
      this.title666 = "编辑订单";
      queryProcess({
        orderId: row.id
      }).then(res => {
        if (res.code == 200) {
          this.steps100 = res.rows;
          console.log(this.steps100[9].finish);
          console.log(this.steps100[12].finish);
          console.log(this.steps100[11].finish);
          console.log(this.steps100, "比对用的数据");
          this.editFlags = false;
          this.dialogVisible = true;
        }
      });
      queryProcess({
        orderId: row.id,
        flowSerial: 17
      }).then(res => {
        if (res.code == 200) {
          this.formData.results = res.rows[0].context
        }
      });
    },
    closeDialog() {
      this.dialogVisible = false;
    },
    // 删除操作
    handleSelectionChange(val) {
      this.ids = val.map(item => item.id);
      this.single = val.length != 1;
      this.multiple = !val.length;
    },
    // 批量删除
    handleDelete(row) {
      const id = row.id || this.ids;
      this.$confirm("是否确认删除?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return delOrder(id);
        })
        .then(() => {
          this.getData00();
          this.msgSuccess("删除成功");
        })
        .catch(function() {});
    },
    //获取数据
    getData00() {
      fetchOrder_org(this.params).then(res => {
        if (res.code == "200") {
          this.tableData = res.rows;
          this.pageTotal = res.total;
          this.loading = false;
        }
      });
    },
    // 触发搜索按钮
    search() {
      this.$set(this.params, "pageNum", 1);
      this.paramsFlag = 0;
      this.getData00();
    },
    // 分页导航
    handlePageChange(val) {
      this.$set(this.params, "pageNum", val);
      this.getData00();
    }
  }
};
</script>

<style scoped>
.resource {
  padding: 30px;
}
.container {
  margin-top: 20px;
}
.handle-box {
  margin-bottom: 10px;
}

.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}
.yellow {
  color: #f57506;
}
.green {
  color: green;
  cursor: pointer;
}
.blue2 {
  color: #409eff;
}
.blue {
  color: #409eff;
  cursor: pointer;
  text-decoration: underline;
}
.mr10 {
  margin-right: 10px;
}

.searchForm .el-form-item--mini.el-form-item,
.searchForm .el-form-item--small.el-form-item {
  margin-bottom: 1px;
}
.study_pic {
  display: block;
  width: 100px;
  height: 85px;
  margin: auto;
  /* border-radius: 50%; */
}
.avatar {
  display: inline-block;
  width: 148px;
  height: 148px;
}
.avatar6 {
  display: inline-block;
  margin-right: 10px;
  position: relative;
}
.avatar6 img {
  width: 200px;
}
.progress_box {
  width: 100%;
  display: flex;
  box-sizing: border-box;
  padding: 10px 30px;
  margin: 0 auto;
  justify-content: space-between;
  background-color: #fff;
  /* align-items: center; */
}
.progress_box .left {
  width: 15%;
  color: #888;
  font-size: 14px;
}
.progress_box .left_c {
  width: 15%;
  color: #444;
  font-weight: bold;
  font-size: 14px;
}
.progress_box .right {
  width: 75%;
  color: #888;
  font-size: 14px;
}
.progress_box .right_c {
  width: 75%;
  color: #444;
  font-size: 14px;
}
.progress_box .center {
  width: 10%;
  text-align: center;
  line-height: 1;
  /* display: flex;
  align-items: center; */
}
.top88 {
  display: flex;
  align-items: center;
}
.title88 {
  display: flex;
  align-items: center;
  margin: 0px 0 10px;
  font-weight: bold;
}
.time88 {
  margin-bottom: 10px;
}
.desc88 {
  margin-bottom: 10px;
}
.loading88 {
  color: #3d6fff;
  margin-left: 40px;
  cursor: pointer;
}

.inpWidth {
  width: 450px;
}
.save_btn {
  display: inline-block;
  margin-left: 20px;
}
.father_box {
  position: relative;
  display: inline-block;
  margin-right: 20px;
}
.son_box {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 240px;
  background-color: rgba(0,0,0,.3);
  text-align: center;
  line-height: 240px;
  font-size: 30px;
  color: #fff;
}
</style>
